package com.yy.tech.data.logger.plugin;

import com.yy.tech.data.logger.context.SpringContext;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.lookup.AbstractLookup;

@Plugin(name = "spring",category = AbstractLookup.CATEGORY)
public class SpringEnvironmentLookup extends AbstractLookup {
    @Override
    public String lookup(LogEvent event, String key) {
        if (null != SpringContext.getEnvironment()){
            return SpringContext.getEnvironment().getProperty(key);
        }
        return null;
    }
}
